/*
 * EventContext.h
 *
 *  Created on: 2014年5月29日
 *      Author: ellzu
 */

#ifndef EVENTCONTEXT_H_
#define EVENTCONTEXT_H_


namespace EventRunLoop {

/**
 * this is interface
 */
class EventContext {
protected:
	EventContext(){}
public:
	virtual ~EventContext(){}
};

template <typename T>
class TEventContext : public EventContext
{
public:
	TEventContext(T *t,bool autoDelete);
	virtual ~TEventContext();
	T* get();
protected:
	T *_t;
	bool _isAutoDelete;
};


// TEventContext cpp
template <typename T>
TEventContext<T>::TEventContext(T *t,bool autoDelete)
{
	_t = t;
	_isAutoDelete = autoDelete;
}

template <typename T>
TEventContext<T>::~TEventContext()
{
	if(_isAutoDelete){
		delete _t;
	}
}

template <typename T>
T* TEventContext<T>::get()
{
	return _t;
}
// end TEventContext cpp

} /* namespace EventRunLoop */

#endif /* EVENTCONTEXT_H_ */
